import axios from "axios";


// eslint-disable-next-line
export default {
    //获取父类
    get: ({ curPage, eachPage }) => axios.get('/api/totalType', {
        //请求的参数
        params: { curPage, eachPage }
        //返回请求到的后台数据
    }).then(res => res.data),

    // 新增
    addTotalType: totalTypeName => {
        console.log({ totalTypeName: totalTypeName });
        return axios.post('/api/totalType/add-totalType', {
            totalTypeName: totalTypeName
        }
        ).then(res => res.data)
    },
    //删除
    deleteTotalType: _id => {
        return axios({ method: "delete", url: "/api/totalType/delete-totalType", data: { _id } }).then(res => res.data)
        // delete(`/api/totalType/delete-totalType`,{params:{_id}})
    },
    //修改
    amendTotalType: (newType) => axios.put('/api/totalType/amend-totalType', newType).then(res => res.data),


    //获取子类所有信息
    getChildType: ({curPage,
        eachPage}) => axios.get('/api/totalType/childType',{curPage,
            eachPage}).then(res => res.data),
    // 新增子类
    addchilddata:(info)=>{
        return axios.post("/api/totalType/addChild",info).then(({data})=>data)

    },
    // 按夫类型查子类型
    selectFromtotal:(info)=>axios.get("/api/totalType/selforTotal",{params:info}).then(({data})=>data),
    // 删除
    deleteone:(info)=>axios.delete("/api/totalType/deloneChild",{params:info}).then(({data})=>data),
    // 修改
    resOneChild:(info)=>axios.patch("/api/totalType/resChildType",info).then(({data})=>data),
    getassType:()=>axios.get("/api/totalType/assType").then(({data})=>data)
}

// return axios({ mathod: "put", url: "/api/totalType/amend-totalType", data: {newType} }).then(res => res.data)
